package doc2db.interfaces.action.templates;

import doc2db.fileWorker.FileBeginer;
import doc2db.interfaces.xmledit.XmlEditorFrame;
import doc2db.interfaces.xmledit.saveTemplatesInDBAction;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;

/**
 *
 * @author yuriy
 */
public class NewTempletAction implements ActionListener {

    @Override
    public void actionPerformed(ActionEvent e) {
        //EventQueue.invokeLater(new Runnable() {
        //@Override
        //public void run() {
        String templates;
        String meta;
        Object[] options = {"Да", "Нет"};
        int n = JOptionPane.showOptionDialog(null,
                "Вставить коментарии?",
                "doc2db - создание шаблона",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE,
                null, //do not use a custom Icon
                options, //the titles of buttons
                options[0]); //default button title
        if (n == JOptionPane.YES_OPTION){
            meta = FileBeginer.getFullMetaTemplates();
            templates = FileBeginer.getFullTemplates();
        } else {
            meta = FileBeginer.getMetaTemplates();
            templates = FileBeginer.getTemplates();
        }

        XmlEditorFrame f = new XmlEditorFrame(templates, meta, true);
        f.setSaveAction(new saveTemplatesInDBAction(f.text1, f.text2, f.textAbout));
        f.setVisible(true);
        //}
        //});
    }
}
